Skip to content

feat(update): add opt-in in-app updates with delta packages and redesign About - #766

Merged
cwuom merged 8 commits into
masterfrom
feat/app-update
Nov 29, 2026
Merged

cwuom merged 8 commits into
masterfrom
feat/app-update

Conversation

@cwuom

@cwuom cwuom commented Nov 29, 2026 •

Copy link
Copy Markdown
Owner

描述 / Description

NeriPlayer has no way to tell users about new builds; they have to watch GitHub Releases by hand. This PR adds an opt-in in-app updater with delta downloads and redesigns the About page around it.

Updates (Settings → About → App updates)

  • Three channels: Release (releases/latest), Nightly (newest nightly-* prerelease) and CI (a new rolling ci-build prerelease). Choosing Nightly or CI shows a risk warning first; switching back to Release does not.
  • Manual check, channel and delta updates are always available. Check automatically is off by default and can be turned on in onboarding (Permissions step) or on the page. It only checks Release, at most once every 6 hours at launch, and prompts with the changelog highlights; a version can be skipped.
  • A build is newer when its build_uuid differs and its build_timestamp is later, so nothing is ever downgraded. The APK is picked by the installed package's ABI.
  • Install goes through a PackageInstaller session with setAppPackageName, so the system always shows its confirmation and refuses a package with another name. There is no pre-check of "install unknown apps": on Android 17 the default "Ask every time" mode reports canRequestPackageInstalls() == false although the system installer would ask anyway.

Delta updates (NPDELTA1)

  • .github/scripts/apk_delta.py inflates the deflated entries of both APKs, diffs the inflated content with bsdiff, and records the zlib level that reproduces each entry. The device patches, deflates those entries again at the same level, and accepts the result only if its SHA-256 matches the release metadata; otherwise it downloads the full APK.
  • Measured on NeriPlayer-693842c8.11262018 → NeriPlayer-91b1379e.11281532 (arm64): 5.3 MB patch vs 15.8 MB APK. Python, JDK and the Android 17 arm64 platform Deflater all reproduced the dex entries byte for byte, and the Kotlin patcher rebuilt the official APK with SHA-256 788f182b….

Release tooling

  • manual_release.yml builds patches against the previous build of the same channel and replays each one before upload. A failed patch step never blocks the release.
  • android_ci.yml gets publish-ci-channel: after every gate passes on a master push, it uploads the APK and patches, overwrites the metadata last, moves the ci-build tag and removes stale assets. Actions artifacts cannot be downloaded without a login, which is why the CI channel needs a release.

About page

  • Brand hero (adaptive launcher icon, theme glow, version/build-type/ABI chips), an App updates entry with live status, build info (version with the 7-tap developer mode, build UUID, build time), project links and a footer. Works in Material and Clean, light and dark.
  • App updates is a second-level page of About (backTargetPage), so back and predictive back return to About.

Risks and compatibility

  • New permission REQUEST_INSTALL_PACKAGES and a non-exported AppUpdateInstallReceiver.
  • New settings keys app_update_check_enabled (default false), app_update_channel (default release) and app_update_delta_enabled (default true); last-check time and skipped build stay in a separate local DataStore and are not exported.
  • The first master push after merge creates the public ci-build prerelease. CI only builds arm64-v8a, so other ABIs see "no package for this device" on that channel.
  • The privacy notice gets one bullet about update checks and its date moves to 2026-11-29.
  • Debug builds cannot install release APKs (different package); the session fails with the install error, by design.

类型 / Type

  • Bug 修复 / Bug fix
  • 新功能 / New feature
  • 文档更新 / Documentation update
  • 其他(请描述)/ Other (please describe): release and CI workflows publish delta patches and the ci-build channel

修复或解决的问题 / Issues fixed or closed by this PR

None (no tracking issue).

清单 / Checklist

  • 我已阅读并遵循贡献指南 / I have read and followed the contribution guidelines
  • 我已在本地测试这些更改 / I have tested these changes locally
  • 我已运行必要的构建、测试或静态检查 / I have run the required build, tests, or static checks
  • 我已更新相关文档或注释(如适用)/ I have updated relevant documentation or comments (if applicable)
  • 本次更改没有破坏原有行为 / This change does not break existing behavior
  • 本次更改向下兼容(如适用)/ This change is backward compatible (if applicable)
  • 没有提交密钥、Token 或其他敏感信息 / No secrets, tokens, or other sensitive information are committed
  • UI 变更已附截图或录屏(如适用)/ UI changes include screenshots or recordings (if applicable)

其他信息 / Additional information

How it was tested (macOS, local):

  • python3 -B -m unittest discover -s .github/scripts -p 'test_*.py': 79 tests pass, including the new test_apk_delta.py. The new workflow shell steps pass bash -n, and the publish-ci-channel step was dry-run against a fake gh for both the first-create and update paths. actionlint was not run locally.
  • New JVM tests cover the patcher (fixtures produced by apk_delta.py), resolver, GitHub source (MockWebServer), downloader with delta fallback, manager state machine, notes parsing, settings wiring and Compose UI for the status card, channel warning and onboarding card.
  • verifyModularization passes (all owned JVM tests, CRAP, domain dependencies, lint). After the last changes, the update, settings, onboarding and architecture tests (600) and :app:lintDebug were rerun and pass. The new core/update code is not added to the CRAP scope.
  • Pixel_10_Pro_XL emulator (API 37) with a debug build stamped older than the latest release: startup prompt, download and SHA-256 check of the 16 MB APK, Nightly and CI checks, channel warning, settings search, About → App updates → back. The install step ends with the expected package-name rejection on a debug build.
  • A release build signed with the release key was installed over an existing release on a OnePlus PLK110 (Android 17). A full self-update install was not exercised: every published build is older than the build on that phone. It needs the first ci-build or Nightly after merge.

Screenshots (emulator, Clean dark) will be attached in a comment, so the screenshot box is left unchecked for now.

🤖 Generated with Claude Code

新增应用内更新,入口为 设置 → 关于 → 应用更新。

  • 支持 Release、Nightly、CI 通道。切换到预览通道前需确认。
  • 自动检查默认关闭。开启后,启动时仅检查 Release,且至少间隔 6 小时。
  • 支持增量补丁。补丁校验失败时回退到完整 APK。
  • 通过 PackageInstaller 安装,需系统确认。新增 REQUEST_INSTALL_PACKAGES 权限及不可导出的接收器。
  • 关于页改为分组页面,包含品牌区、更新状态、构建信息和项目链接。
  • 新增 apk_delta.py 及 CI 发布流程。CI 通道仅提供 arm64-v8a 包。
  • 新增单元测试、Compose 测试及补丁测试。

Add .github/scripts/apk_delta.py, which builds NPDELTA1 patches: it inflates
deflated APK entries, diffs them with bsdiff, and records the zlib level
that reproduces each entry so the device can rebuild the signed APK byte
for byte. Every patch is replayed and checked against the target SHA-256
before it is published.

- manual_release.yml builds patches against the previous build of the
  same channel (latest Release, or the Nightly that is about to be pruned).
  A failed patch step never blocks the release.
- android_ci.yml gets publish-ci-channel: after every gate passes on a
  master push it syncs the APK, patches and metadata to the rolling
  ci-build prerelease, because Actions artifacts need a login to download.
Settings → About → App updates checks GitHub Releases on three channels:
Release, Nightly and CI (the rolling ci-build prerelease). Manual checks,
the channel picker and delta updates are always available. Automatic
checks are off by default, can be turned on during setup or on that page,
and only prompt at launch for Release builds that were not skipped.
Switching to Nightly or CI asks for confirmation first.

- core/update resolves the newest build by build UUID and timestamp,
  prefers a delta patch that matches the installed APK, verifies every
  file with SHA-256, falls back to the full APK, and installs through a
  PackageInstaller session so the system always confirms.
- The About page gets a brand hero, an update entry, build info and
  project links. App updates is nested under About so back returns there.
- The privacy notice, READMEs and contributing guides describe the new
  behaviour and the release tooling.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-29T04:30:36.644108Z 7294ddb New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7f344b0a70

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review
Walkthrough

新增客户端应用更新流程,涵盖 GitHub 发布读取、版本解析、APK 下载、增量补丁应用和系统安装。新增更新设置页、启动提示与 About 页面内容。新增 NPDELTA1 补丁工具,并将补丁生成接入 CI 和手动发布工作流。

Merge Risk: Low · previous review 1dd32 · assessed changes only

Path filters excluded changed files. This rating applies only to the assessed changes.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 标题“feat(update): add opt-in in-app updates with delta packages and redesign About”准确概括了本 PR 的主要变更:可选启用的应用内更新(含 Release/Nightly/CI 通道)、增量补丁(NPDELTA1)以及关于页重新设计。变更集中的更新模块、设置项、关于页、CI 与发布脚本均与标题相符。标题长度为 78 …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

标题“feat(update): add opt-in in-app updates with delta packages and redesign About”准确概括了本 PR 的主要变更:可选启用的应用内更新(含 Release/Nightly/CI 通道)、增量补丁(NPDELTA1)以及关于页重新设计。变更集中的更新模块、设置项、关于页、CI 与发布脚本均与标题相符。标题长度为 78 个字符,略长,但仍简洁且具体。

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.

Other comments: 8

app/src/main/java/moe/ouom/neriplayer/core/update/download/InstalledApkInspector.kt: 1

39-39: Minor · Functional Correctness · Quick win

不要缓存读取失败的 APK 摘要

如果首次读取已安装 APK 时遇到临时 IOException,这里会把 null 和文件键一起缓存。文件恢复可读后,只要路径、大小和修改时间未变,后续检查就不会重试。即使发布版本提供匹配的增量包,用户也只能下载完整 APK。

只缓存成功读取的摘要。读取失败时,本次检查仍可回退到完整包,下次检查则重新计算摘要。

app/src/main/java/moe/ouom/neriplayer/core/update/download/AppUpdateDownloader.kt: 1

130-130: Minor · Stability & Availability · Quick win

在取消时立即中断 OkHttp 调用

如果用户在 call.execute() 或响应体读取阻塞时取消下载,invokeOnCompletion 要等协程完成后才调用 call.cancel()。阻塞操作却必须先返回,协程才能完成。循环中的 ensureActive() 也无法中断正在进行的读取。因此,取消后下载仍可能等到网络恢复或超时才释放连接和 .part 文件。

使用在协程取消时调用 Call.cancel() 的桥接,并让它覆盖整个响应体读取过程。保留 finally 中的清理,以及取消后不回退到完整下载的行为。

app/src/main/java/moe/ouom/neriplayer/core/update/delta/ApkDeltaPatcher.kt: 2

39-39: Minor · Stability & Availability · Quick win

在展开基础 APK 时响应取消

如果用户在展开阶段取消下载,expandBase 仍会继续读取、解压并写入临时文件。下载器只在进度回调中检查取消,而展开开始后,下一次回调要等整个展开结束。用户取消后,应用仍可能继续占用 CPU 和磁盘。

将取消检查传入展开逻辑,并在复制和解压循环中按块执行。检查抛出的 CancellationException 可以沿用现有清理路径;未取消时,展开结果不变。


185-185: Minor · Stability & Availability · Quick win

为 openStream 返回的解压流补充 Inflater 释放逻辑。

openStream 把在调用处创建的 Inflater(true) 交给 InflaterInputStream。按 OpenJDK 实现,只有包装流自己创建默认 Inflater 时,close() 才会调用 end()。这里传入的实例不属于这种情况。openStream 返回的类型是 InputStream,调用方无法访问该 Inflater,因此没有代码调用它的 end()。每个分段的原生 zlib 状态都要等待对象被回收,才会释放。

建议修改

     private fun openStream(patch: File, offset: Long, length: Long): InputStream {
         val raw = FileInputStream(patch)
         raw.channel.position(offset)
-        return InflaterInputStream(BoundedInputStream(raw, length), Inflater(true), bufferSize)
+        val inflater = Inflater(true)
+        return object : InflaterInputStream(BoundedInputStream(raw, length), inflater, bufferSize) {
+            override fun close() {
+                try {
+                    super.close()
+                } finally {
+                    inflater.end()
+                }
+            }
+        }
     }
app/src/main/java/moe/ouom/neriplayer/core/update/delta/ApkDeltaPatchFile.kt: 1

98-98: Minor · Functional Correctness · Quick win

在解析增量补丁时,范围边界检查可能因 Long 加法回绕而失效。

inflateRanges 与 deflateRanges 没有检查 offset 与 blobOffset 的范围。第 98 行的 range.offset + range.compressedSize 与第 113 行的 range.end(blobOffset + uncompressedSize)在接近 Long.MAX_VALUE 时会回绕为负数。这样,越界的记录可以通过解析检查,并使后续的顺序检查失效。该补丁会在 expandBase 或最终摘要校验阶段才失败,而不是在解析时被拒绝。

最终 SHA-256 校验仍会阻止错误的 APK 被安装。问题在于补丁校验的时机和失败路径:本应在解析时拒绝的补丁,会进入应用阶段。

建议先比较 offset 与 fileSize,再用减法比较长度。因为 offset 已确认不超过 fileSize,减法不会溢出。blobOffset 也使用同样的方法。

建议修改

-                if (range.offset < position || range.offset + range.compressedSize > fileSize) {
+                if (range.offset < position || range.offset > fileSize || range.compressedSize > fileSize - range.offset) {
-                if (range.blobOffset < position || range.end > blobSize) {
+                if (range.blobOffset < position || range.blobOffset > blobSize || range.uncompressedSize > blobSize - range.blobOffset) {
app/src/main/java/moe/ouom/neriplayer/core/update/AppUpdateManager.kt: 1

83-85: Minor · Functional Correctness · Quick win

切换通道时,进行中的检查结果仍会按旧通道发布。

设置页在检查期间仍允许切换通道,且切换后会调用 discardResult()。当状态为 Checking 时,discardResult() 不做任何操作,因为 isBusy 包含 Checking。runCheck() 在开始时读取一次通道并用于请求和解析,完成后直接写入 Available、UpToDate 或 NoCompatibleBuild,不检查当前通道是否仍被选中。

因此,若用户在检查请求期间切换通道,旧通道的 Available 候选会保留在界面上。downloadAndInstall() 从 state.value.candidate 开始下载和安装,用户可能安装旧通道的版本。系统安装确认仍会出现,因此影响限于用户确认后的安装。

切换通道后,进行中的检查必须失效,且旧检查不得提交结果。checkForStartupPrompt() 直接调用 runCheck(),不经过 checkJob,因此只取消 checkJob 无法覆盖该路径。

app/src/main/java/moe/ouom/neriplayer/ui/screen/tab/settings/update/AppUpdateStatusCard.kt: 1

143-143: Minor · Functional Correctness · Quick win

让“上次检查”的时间随时间流逝更新。

检查完成后,如果用户保持页面打开且没有触发重组,System.currentTimeMillis() 不会再次求值。十分钟后,页面仍显示最初计算的相对时间,导致“上次检查”信息失真。

请改用绝对时间,或在页面可见期间定时更新当前时间。

.github/workflows/android_ci.yml: 1

632-634: Minor · Functional Correctness · Quick win

防止较旧构建覆盖较新 CI 渠道。

如果较旧提交 A 的构建比提交 B 慢,B 可以先通过门禁并完成发布。A 随后进入此并发组,仍会覆盖 B 的元数据,并在 Line 695 强制将 ci-build 标签移回 A。串行发布不能保证构建按新旧顺序发布。

请在发布前增加过时构建检查,拒绝覆盖已经发布的较新构建。否则,CI 渠道会持续提供旧 APK,直到下一次成功发布。

As per path instructions,本问题属于允许报告的 “ineffective concurrency”。

Source: Path instructions

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 2986103 and 7f344b0.

Files ignored due to path filters: 6

  • CONTRIBUTING.md is excluded by !**/*.md
  • CONTRIBUTING_EN.md is excluded by !**/*.md
  • README.md is excluded by !**/*.md
  • README_EN.md is excluded by !**/*.md
  • app/src/test/resources/update/delta/base.zip is excluded by !**/*.zip
  • app/src/test/resources/update/delta/target.zip is excluded by !**/*.zip
Files selected for processing: 75

  • .github/scripts/apk_delta.py
  • .github/scripts/test_apk_delta.py
  • .github/workflows/android_ci.yml
  • .github/workflows/manual_release.yml
  • app/build.gradle.kts
  • app/src/main/AndroidManifest.xml
  • app/src/main/java/moe/ouom/neriplayer/activity/MainActivity.kt
  • app/src/main/java/moe/ouom/neriplayer/core/update/AppUpdateManager.kt
  • app/src/main/java/moe/ouom/neriplayer/core/update/AppUpdateModels.kt
  • app/src/main/java/moe/ouom/neriplayer/core/update/AppUpdateNotes.kt
  • app/src/main/java/moe/ouom/neriplayer/core/update/AppUpdatePolicy.kt
  • app/src/main/java/moe/ouom/neriplayer/core/update/AppUpdateState.kt
  • app/src/main/java/moe/ouom/neriplayer/core/update/AppUpdateStateStore.kt
  • app/src/main/java/moe/ouom/neriplayer/core/update/delta/ApkDeltaPatchFile.kt
  • app/src/main/java/moe/ouom/neriplayer/core/update/delta/ApkDeltaPatcher.kt
  • app/src/main/java/moe/ouom/neriplayer/core/update/delta/RecompressingOutputStream.kt
  • app/src/main/java/moe/ouom/neriplayer/core/update/download/AppUpdateDownloader.kt
  • app/src/main/java/moe/ouom/neriplayer/core/update/download/InstalledApkInspector.kt
  • app/src/main/java/moe/ouom/neriplayer/core/update/install/AppUpdateInstallReceiver.kt
  • app/src/main/java/moe/ouom/neriplayer/core/update/install/AppUpdateInstaller.kt
  • app/src/main/java/moe/ouom/neriplayer/core/update/release/AppUpdateFeed.kt
  • app/src/main/java/moe/ouom/neriplayer/core/update/release/AppUpdateResolver.kt
  • app/src/main/java/moe/ouom/neriplayer/core/update/release/GitHubAppUpdateSource.kt
  • app/src/main/java/moe/ouom/neriplayer/ui/dialog/StartupAppUpdatePrompt.kt
  • app/src/main/java/moe/ouom/neriplayer/ui/onboarding/StartupOnboardingExtras.kt
  • app/src/main/java/moe/ouom/neriplayer/ui/onboarding/StartupOnboardingScreen.kt
  • app/src/main/java/moe/ouom/neriplayer/ui/onboarding/StartupPrivacyStep.kt
  • app/src/main/java/moe/ouom/neriplayer/ui/screen/tab/settings/SettingsScreen.kt
  • app/src/main/java/moe/ouom/neriplayer/ui/screen/tab/settings/about/SettingsAboutHero.kt
  • app/src/main/java/moe/ouom/neriplayer/ui/screen/tab/settings/about/SettingsAboutInteractions.kt
  • app/src/main/java/moe/ouom/neriplayer/ui/screen/tab/settings/about/SettingsAboutSection.kt
  • app/src/main/java/moe/ouom/neriplayer/ui/screen/tab/settings/component/AutoSettingSpecItems.kt
  • app/src/main/java/moe/ouom/neriplayer/ui/screen/tab/settings/navigation/SettingsNavigationState.kt
  • app/src/main/java/moe/ouom/neriplayer/ui/screen/tab/settings/page/SettingsPage.kt
  • app/src/main/java/moe/ouom/neriplayer/ui/screen/tab/settings/page/SettingsPageGlyphs.kt
  • app/src/main/java/moe/ouom/neriplayer/ui/screen/tab/settings/page/SettingsPageIconMapper.kt
  • app/src/main/java/moe/ouom/neriplayer/ui/screen/tab/settings/page/SettingsSearchIndex.kt
  • app/src/main/java/moe/ouom/neriplayer/ui/screen/tab/settings/update/AppUpdateChannelSetting.kt
  • app/src/main/java/moe/ouom/neriplayer/ui/screen/tab/settings/update/AppUpdatePresentation.kt
  • app/src/main/java/moe/ouom/neriplayer/ui/screen/tab/settings/update/AppUpdateReleaseNotes.kt
  • app/src/main/java/moe/ouom/neriplayer/ui/screen/tab/settings/update/AppUpdateStatusCard.kt
  • app/src/main/java/moe/ouom/neriplayer/ui/screen/tab/settings/update/SettingsAppUpdatePage.kt
  • app/src/main/java/moe/ouom/neriplayer/ui/settings/AutoSettingsUi.kt
  • app/src/main/java/moe/ouom/neriplayer/ui/settings/SettingGlyphs.kt
  • app/src/main/res/values-en/strings_about.xml
  • app/src/main/res/values-en/strings_app_update.xml
  • app/src/main/res/values-en/strings_onboarding.xml
  • app/src/main/res/values-zh/strings_about.xml
  • app/src/main/res/values-zh/strings_app_update.xml
  • app/src/main/res/values-zh/strings_onboarding.xml
  • app/src/main/res/values/strings_about.xml
  • app/src/main/res/values/strings_app_update.xml
  • app/src/main/res/values/strings_onboarding.xml
  • app/src/test/java/moe/ouom/neriplayer/core/update/AppUpdateManagerTest.kt
  • app/src/test/java/moe/ouom/neriplayer/core/update/AppUpdateNotesTest.kt
  • app/src/test/java/moe/ouom/neriplayer/core/update/AppUpdateStateStoreTest.kt
  • app/src/test/java/moe/ouom/neriplayer/core/update/AppUpdateTestFixtures.kt
  • app/src/test/java/moe/ouom/neriplayer/core/update/delta/ApkDeltaPatcherTest.kt
  • app/src/test/java/moe/ouom/neriplayer/core/update/download/AppUpdateDownloaderTest.kt
  • app/src/test/java/moe/ouom/neriplayer/core/update/download/InstalledApkInspectorTest.kt
  • app/src/test/java/moe/ouom/neriplayer/core/update/release/AppUpdateResolverTest.kt
  • app/src/test/java/moe/ouom/neriplayer/core/update/release/GitHubAppUpdateSourceTest.kt
  • app/src/test/java/moe/ouom/neriplayer/ui/onboarding/StartupOnboardingExtrasComposeTest.kt
  • app/src/test/java/moe/ouom/neriplayer/ui/screen/tab/SettingsNavigationPolicyTest.kt
  • app/src/test/java/moe/ouom/neriplayer/ui/screen/tab/settings/update/AppUpdateSettingsComposeTest.kt
  • app/src/test/java/moe/ouom/neriplayer/ui/screen/tab/settings/update/AppUpdateSettingsWiringTest.kt
  • app/src/test/resources/update/delta/patch.npdelta
  • ksp-annotations/src/main/kotlin/moe/ouom/neriplayer/ksp/annotations/AutoSetting.kt
  • modules/common/src/main/res/values-en/strings_settings_update.xml
  • modules/common/src/main/res/values-zh/strings_settings_update.xml
  • modules/common/src/main/res/values/strings_settings_update.xml
  • modules/local/src/main/java/moe/ouom/neriplayer/data/settings/AutoSettingsSchema.kt
  • modules/local/src/main/java/moe/ouom/neriplayer/data/settings/update/AppUpdateSettingsSection.kt
  • modules/local/src/test/java/moe/ouom/neriplayer/data/settings/AutoSettingsGeneratedTest.kt
  • modules/model/src/main/java/moe/ouom/neriplayer/data/model/settings/update/AppUpdateChannel.kt

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

- Cancel an in-flight check when the channel changes, and drop a result
  whose channel is no longer selected.
- Skip the startup cleanup while a download or install is running, so an
  Activity recreation no longer deletes the partial file or patch work dir.
- Download through awaitResponse so cancelling closes the socket at once
  instead of waiting for a blocked read.
- A 404 for a package drops the offer, and a failed download offers a
  fresh check next to Retry, so a superseded CI or Nightly build is not
  requested again and again.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.

Other comments: 4

app/src/test/java/moe/ouom/neriplayer/core/update/download/AppUpdateDownloaderTest.kt: 1

144-145: Minor · Functional Correctness · Quick win

等待响应体开始读取后再取消。

如果 Dispatchers.IO 尚未执行下载协程,delay(300) 就已结束,cancelAndJoin() 会直接取消尚未开始的任务。此时,即使下载期间的取消已失效,耗时和空目录断言仍会通过。

请用首次下载进度等明确事件确认响应体已开始读取,再取消任务。取消耗时应从调用取消时开始计算,避免把调度等待计入取消耗时。

app/src/main/java/moe/ouom/neriplayer/core/update/AppUpdateManager.kt: 2

82-82: Minor · Functional Correctness · Quick win

取消旧检查后,需要阻止旧任务覆盖新结果。

cancel() 不会等待旧任务退出。discardResult() 随即发布 Idle,此时 check() 可以启动新检查。如果新检查先发布 Available,旧任务随后进入 runCheck() 的取消处理,Line 208 会将新结果覆盖为 Idle。用户会丢失刚取得的更新候选。

请用检查任务身份限制状态写入,或串行完成旧任务取消后再允许新检查。正常取消仍应返回 Idle,但不能清除后续检查的结果。


92-94: Minor · Stability & Availability · Quick win

启动清理与新下载并发时,会删除正在使用的 .part 文件。

checkForStartupPrompt() 在第 92 行检查忙碌状态后,才通过 withContext(io) 调度 clearStaleDownloads()。在调度完成前,用户可以启动 downloadAndInstall()。它只检查 Installing 状态和活动的 downloadJob,不会阻止此时开始下载。

clearStale() 会删除所有以 .part 结尾的文件、所有目录,以及超过一天的文件。下载器写入的 <apk>.part 和增量路径使用的 work 目录都会被删除。完整下载路径会在 renameTo 时失败,并报告存储错误。增量路径会先失败,再回退到完整下载。

清理和下载启动需要使用同一把互斥锁,或在清理执行前再次检查状态,并在持有锁期间完成检查。这样可以保证清理不会与任何活动下载文件并发。

影响范围

该问题只在检查后、清理执行前的短暂窗口内触发,用户可以重新下载,因此影响较小。

app/src/main/java/moe/ouom/neriplayer/ui/screen/tab/settings/update/AppUpdateStatusCard.kt: 1

233-238: Minor · Functional Correctness · Quick win

失败后保留发布页入口

下载失败且候选版本存在时,此分支隐藏了发布页按钮。用户因此无法从失败卡片打开发布页进行手动恢复。请同时保留检查按钮和发布页入口。

As per path instructions,app/src/main/**/*.kt 应仅报告有可观察影响的具体缺陷;此处影响失败后的恢复操作。

Source: Path instructions

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 7f344b0 and 1dd3223.

Files selected for processing: 6

  • app/src/main/java/moe/ouom/neriplayer/core/update/AppUpdateManager.kt
  • app/src/main/java/moe/ouom/neriplayer/core/update/download/AppUpdateDownloader.kt
  • app/src/main/java/moe/ouom/neriplayer/ui/screen/tab/settings/update/AppUpdateStatusCard.kt
  • app/src/test/java/moe/ouom/neriplayer/core/update/AppUpdateManagerTest.kt
  • app/src/test/java/moe/ouom/neriplayer/core/update/download/AppUpdateDownloaderTest.kt
  • app/src/test/java/moe/ouom/neriplayer/ui/screen/tab/settings/update/AppUpdateSettingsComposeTest.kt

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

Until the rolling ci-build prerelease exists, the CI channel reads the
latest successful Android CI run on master whose neri-apk artifact has not
expired. A run from the installed commit, or one that started before this
build, counts as up to date; a newer run is shown as a new CI build with a
link to the run, because Actions artifacts need a GitHub login.
- Tag each check with a generation so a cancelled or superseded check can
  no longer overwrite a newer result, and share a file lock between
  downloads and the startup cleanup.
- Report progress while expanding the base APK so cancellation is
  noticed there too, end the Inflater behind each patch stream, and make
  the patch range checks overflow-safe.
- Cache the installed APK digest only after a successful read.
- Keep the release page next to Retry and Check for updates on failure.
- Shorten the up-to-date title, move "newer than this channel" into the
  detail line, split the subtitle into two lines and show the last check
  as a clock time instead of a relative time that went stale.
- publish-ci-channel skips a build older than the one ci-build already
  serves, since serial publishing does not keep commit order.
@cwuom

cwuom commented Nov 29, 2026

Copy link
Copy Markdown
Owner Author

Addressed the grouped CodeRabbit findings in 1dd3223 and 5fe6eeb:

  • Installed APK digest: only a successful read is cached now.
  • OkHttp cancellation: downloads go through awaitResponse, so cancelling closes the call immediately (1dd3223).
  • Base APK expansion: progress is reported per entry, so cancellation is noticed during expansion.
  • openStream: the Inflater is ended when its stream closes.
  • Patch range checks: the offset is checked against the bound first and lengths are compared by subtraction, so Long overflow can't pass parsing (new malformed-header case).
  • Channel switch during a check: checks carry a generation; discardResult invalidates it and a late result is dropped, including the startup path (1dd3223, 5fe6eeb).
  • Old check overwriting a new result after cancel: covered by the same generation guard, with a regression test.
  • Startup cleanup vs. a new download: both share a Mutex; cleanup only runs if it can take the lock.
  • "Last checked" time: shown as a clock time instead of a relative time.
  • Failed card: the release page button stays next to Retry and Check for updates.
  • publish-ci-channel: skips a build older than the one ci-build already serves.
  • Cancel test: waits for the first progress event before cancelling and times only the cancellation.

🤖 Addressed by Claude Code

Long version names were truncated with an ellipsis when both shared one
line. Each version now gets its own line and wraps instead of being cut.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2957602741

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…ckage

An arm64 device running the armeabi-v7a APK only searched for armeabi-v7a
packages, so the arm64-only CI build was reported as incompatible. The
installed ABI still comes first; the device's other ABIs follow.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2efc75d3f3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

awaitResponse returned as soon as the coroutine was cancelled while the
OkHttp callback could still be writing, so the partial file and file lock
were released early and a late progress callback set the state back to
Downloading. The socket is still cancelled at once, but the download now
waits for the writer to exit, and progress from a cancelled job is dropped.
@cwuom
cwuom merged commit 2fd4078 into master Nov 29, 2026
19 checks passed
@cwuom
cwuom deleted the feat/app-update branch November 29, 2026 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant